package com.example.basic;

public class AccountTest implements Runnable{
    private Integer totalMoney=1000;
    @Override
    public  void run() {
        Integer money=100;
        synchronized (AccountTest.class){
            totalMoney=totalMoney-money;
            System.out.println(totalMoney);
        }
    }

    public static void main(String[] args) {
        AccountTest accountTest = new AccountTest();
        new Thread(accountTest,"A").start();
        new Thread(accountTest,"B").start();
        new Thread(accountTest,"C").start();
        new Thread(accountTest,"D").start();
        new Thread(accountTest,"E").start();
    }
}
